<template>
  <div class="read-detail">
    <!-- 头部 -->
    <div class="detail-header-container">
      <div class="m-center">
        <div class="header">
          <div class="img-box">
            <img :src="readDetail.img" alt="">
          </div>
          <div class="header-content">
            <h3 class="title">
              {{ readDetail.title }}
            </h3>
            <p class="desc">
              {{ readDetail.des }}
            </p>
            <p class="other-info">
              <span class="teacher-info">{{ readDetail.author }} / {{ readDetail.job }}</span>
            </p>
            <p class="read-btn">
              <span v-if="readDetail.type == 'vip'" class="vip">{{readDetail.type}}</span>
              <span v-else class="free">{{readDetail.type}}</span>
            </p>
          </div>
        </div>
      </div>
    </div>

    <!-- 列表 -->
    <div class="m-center">
      <div class="read-list">
        <div class="left" v-html="readDetail.content"></div>
      </div>
      <comment :data="content"/>
      <br/>
      <br/>
    </div>
  </div>
</template>
<script>
import { getArticleDetail } from 'api/article.js'
import { ERR_OK } from 'api/config.js'
export default {
  data () {
    return {
      readDetail: {} // 专栏详情数据
    }
  },
  mounted () {
    this.getReadDetailData()
  },
  methods: {
    getReadDetailData () {
      let id = this.$route.params.id
      getArticleDetail(id).then(res => {
        let { code, data } = res
        if (code === ERR_OK) {
          this.readDetail = data
        }
      })
    }
  },
  computed: {
    content () {
      return this.readDetail
    },
  },
  components: {
    Comment: () => import('components/comment/comment.vue'),
  },
}
</script>
<style lang="css">

</style>
<style lang="stylus" scoped>
  @import '~assets/stylus/variables.styl';
  @import '~assets/stylus/mixin.styl';
  @import '~assets/github.css';
  .read-detail
    .detail-header-container
      height: 244px;
      background-color: #383d42;
      .header
        display: flex;
        align-items: flex-start;
        padding-top: 24px;
        .img-box
          flex: 0 0 144px
          img-box(144px, 190px);
          & > img
            border-radius: 12px;
        .header-content
          flex: 1;
          position: relative;
          margin-left: 40px;
          height: 190px;
          .title
            padding: 8px 0 16px;
            font-size: 24px;
            color: #fff;
            line-height: 24px;
          .desc
            padding-bottom: 16px;
            padding-left: 0;
            padding-right: 50px;
            font-size: 16px;
            color: #fff;
          .other-info
            padding-bottom: 16px;
            font-size: 14px;
            color: rgba(255,255,255,0.6);
          .price
            margin-bottom: 16px;
            font-size: 24px;
            line-height: 32px;
            color: #fff;
          .read-btn
            position: absolute;
            left: 0;
            bottom: 0;
            & > span
              display: inline-block;
              vertical-align: middle;
              margin-right: 20px;
              padding: 8px 24px;
              border-radius: 24px;
              background-color: #fff;
              color: $theme-blue-color;
              line-height: 24px;
              cursor: pointer;
              &.free
                background-color: $theme-blue-color;
                color: #fff;
              &.vip
                background-color: $theme-red-color;
                color: #fff;

    .read-list
      display: flex;
      align-items: flex-start;
      margin-top: 40px;
      margin-bottom: 40px;
      .left
        flex: 1;
        padding: 16px 32px;
        background-color: #fff;
        border-radius: 4px;
        box-shadow: 0 0 8px 4px rgba(7,17,27,0.1);
        box-sizing: border-box;
</style>
